package com.sskj.uboex.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.lib.bean.StockCoinBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.uboex.bean.ProfileRefreshBean;
import com.sskj.uboex.http.HttpConfig;
import com.sskj.uboex.ui.activity.MarketActivity;

import java.util.List;


public class MarketActivityPresenter extends BasePresenter<MarketActivity> {

    public void getProduct(String code) {
        httpService.getProduct(code)
                .execute(new JsonCallBack<HttpData<List<StockCoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<StockCoinBean>>> response) {
                        HttpData<List<StockCoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            RxBus.getDefault().post(new ProfileRefreshBean(httpData.getData().get(0)));
                            mView.refreshCoin(httpData.getData().get(0).getStockProductVO());
                        }
                    }
                });
    }
}
